import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import {rules} from '/@/utils/helper/validator';
import {render} from '/@/utils/common/renderUtils';
import {getWeekMonthQuarterYear} from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
	// {
	//   title: 'chargingOrder',
	//   align: 'center',
	//   dataIndex: 'name',
	//   slots: { customRender: 'name' },
	// },
	{
		title: 'VIN',
		align: 'center',
		dataIndex: 'vin',
	},
	{
		title: '充电开始时间',
		align: 'center',
		dataIndex: 'chargingStartTime',
	},
	{
		title: '充电结束时间',
		align: 'center',
		dataIndex: 'chargingEndTime',
	},
	{
		title: '充电站',
		align: 'center',
		dataIndex: 'chargingStation_dictText',
	},
	{
		title: '充电桩',
		align: 'center',
		dataIndex: 'imei_dictText',
	},
	{
		title: '运营商',
		align: 'center',
		dataIndex: 'operatorId_dictText',
	},
	{
		title: '充电电量（度）',
		align: 'center',
		sorter: true,
		dataIndex: 'electricEnergy',
	},
	{
		title: '充电时长（小时）',
		align: 'center',
		sorter: true,
		dataIndex: 'chargingTime',
	},
	{
		title: '充电结束soc (%)',
		align: 'center',
		dataIndex: 'finallySoc',
	},
	{
		title: '停机原因',
		align: 'center',
		dataIndex: 'chargingClosingDown',
	},
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
		label: 'VIN',
		field: 'vin',
		component: 'Input',
		colProps: {span: 6},
	},
	{
		label: '所属运营商',
		field: 'operatorId',
		component: 'Select',
		slot: 'operatorIdSlot',
	},
	{
		label: '所属充电站',
		field: 'stationId',
		component: 'Select',
		slot: 'stationIdSlot',
	},
	{
		label: '充电电量/度(大于)',
		field: 'electricEnergy',
		component: 'Input',
		colProps: {span: 8},
	},
	{
		label: '充电时长/小时（大于）',
		field: 'chargingTime',
		component: 'Input',
		colProps: {span: 8},
	},
];
//表单数据
export const formSchema: FormSchema[] = [
	{
		label: 'VIN',
		field: 'vin',
		component: 'Input',
		dynamicRules: ({model, schema}) => {
			return [{required: true, message: '请输入VIN!'}];
		},
	},
	{
		label: '充电开始时间',
		field: 'startTime',
		component: 'Input',
		dynamicRules: ({model, schema}) => {
			return [{required: true, message: '请输入充电开始时间!'}];
		},
	},
	{
		label: '充电结束时间',
		field: 'endTime',
		component: 'Input',
		dynamicRules: ({model, schema}) => {
			return [{required: true, message: '请输入充电站!'}];
		},
	},
	{
		label: '充电站',
		field: 'chargingStation_dictText',
		component: 'Input',
		dynamicRules: ({model, schema}) => {
			return [{required: true, message: '请输入充电站!'}];
		},
	},
	{
		label: '充电桩',
		field: 'electricEnergy',
		component: 'Input',
		dynamicRules: ({model, schema}) => {
			return [{required: true, message: '请输入近30天充电时长!'}];
		},
	},
	{
		label: '运营商',
		field: 'operatorId_dictText',
		component: 'Input',
		dynamicRules: ({model, schema}) => {
			return [{required: true, message: '请输入运营商!'}];
		},
	},
	{
		label: '充电电量（度）',
		field: 'electricEnergy',
		component: 'InputNumber',
		dynamicRules: ({model, schema}) => {
			return [{required: true, message: '请输入充电电量（度）'}];
		},
	},
	{
		label: '充电时长（小时）',
		field: 'chargingTime',
		component: 'InputNumber',
		dynamicRules: ({model, schema}) => {
			return [{required: true, message: '请输入充电时长（小时）'}];
		},
	},
	{
		label: '充电结束soc (%)',
		field: 'chargingHighWarnNum',
		component: 'Input',
		dynamicRules: ({model, schema}) => {
			return [{required: true, message: '请输入充电结束soc (%)!'}];
		},
	},

	// TODO 主键隐藏字段，目前写死为ID
	{
		label: '',
		field: 'id',
		component: 'Input',
		show: false,
	},
];

// 高级查询数据
export const superQuerySchema = {
	name: {title: '运营商名称', order: 0, view: 'text', type: 'string'},
	vin: {title: 'VIN', order: 1, view: 'text', type: 'string'},
	chargingStation_dictText: {title: '充电站', order: 2, view: 'text', type: 'string'},
	operatorId_dictText: {title: '运营商', order: 3, view: 'text', type: 'string'},
	chargingStation_dictTextCount: {title: '充电电量（度）', order: 4, view: 'number', type: 'number'},
	totalPower: {title: '充电时长（小时）', order: 5, view: 'number', type: 'number'},
	contactPerson: {title: '充电结束soc (%)', order: 6, view: 'text', type: 'string'},
	startTime: {title: '充电开始时间', order: 7, view: 'text', type: 'string'},
	createTime: {title: '创建时间', order: 8, view: 'date', type: 'string'},
	logo: {title: '运营商Logo URL', order: 9, view: 'image', type: 'string'},
	endTime: {title: '充电结束时间', order: 10, view: 'text', type: 'string'},
};

/**
 * 流程表单调用这个方法获取formSchema
 * @param param
 */
export function getBpmFormSchema(_formData): FormSchema[] {
	// 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
	return formSchema;
}
